<template>
  <el-row class="BaseInfo">
    <!-- 个人信息 -->
    <el-col :span="6" class="pd15 height-24">
      <div class="info-card bg-grey">
        <div class="head row-start-col-center">
          <div class="title">个人信息</div>
        </div>
        <div class="content">
          <div class="user-wrap row-start-col-center">
            <img v-if="userInfo?.avatar" class="avatar" :src="userInfo?.avatar">
            <img v-else class="avatar" src="@/assets/image/avatar.png">
            <div class="user-info relposition">
              <div class="name" :title="userInfo?.nickName || ''">{{ userInfo?.nickName }}</div>
              <div class="status">
                <div class="status-tag" :class="userInfo?.isAuth === 1 ? 'green' : 'orange'">{{
                  userInfo?.isAuth | userAuthFilter }}</div>
               </div>
              <div class="col-center absposition showMouse" style="bottom:0px;right:0px;" @click="openSignUrl">
                  <img style="width:38px;height:38px" src="@/assets/image/sign.png">
                  <div class="color-grey fs12">（制作签章）</div>
              </div>
            </div>
          </div>
          <div class="company-wrap">
            <div class="info-item">
              <div class="label">关联企业：{{ userInfo?.companyId === null ? '无' : '' }}</div>
              <div class="value" v-if="userInfo?.companyId !== null">
                <span class="text">{{ userInfo?.companyName }}</span>
                <div v-if="userInfo?.companyTypeName" class="desc">({{ userInfo?.companyTypeName }})</div>
              </div>
            </div>
            <div class="info-item">
              <!-- <div class="label">企业码：</div> -->
              <div>
                <div class="qrcode" ref="qrcodeRef"></div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </el-col>
    <!-- 认证信息 -->
    <el-col :span="9" class="pd15 height-24">
      <div class="info-card">
        <div class="head row-start-col-center">
          <div class="title">认证信息</div>
        </div>
        <div class="content">
          <div class="rz-wrap">
            <div class="rz-item">
              <div class="label">企业信息认证</div>
              <div class="value">
                <div class="status-tag" :class="userInfo?.isAuth === 1 ? 'green' : 'orange'">
                   <div v-if="userInfo?.isAuth === 1">
                        已认证
                   </div>
                   <div v-else>
                        <div v-if="userInfo?.isCompanyAuth === 1">
                              <div>未指定经办人</div>
                        </div>
                        <div v-else>
                            未认证
                        </div>
                   </div>
                </div>
                 <el-button v-if="!userInfo?.isAuthCompany" type="primary" size="small" plain class="blue-btn"
                  @click="goToAuth">去企业信息认证</el-button>
                <el-button v-if="!userInfo?.isAuth" type="primary" size="small" plain class="blue-btn"
                  @click="goToAuth">去指定经办人</el-button>
                <el-button v-else type="primary" size="small" plain class="blue-btn"
                  @click="updataAgentInfo">修改经办人</el-button>
              </div>
            </div>
            <div class="rz-item">
              <div class="label">服务券配额资格</div>
              <div class="value">
                <div class="status-tag" :class="userInfo?.isVoucherApplicable === 1 ? 'green' : 'orange'">
                  {{ userInfo?.isVoucherApplicable | isVoucherApplicableFilter }}</div>
                <el-button v-if="userInfo.isVoucherApplicable" type="primary" size="small" plain class="blue-btn"
                  @click="goToCouponApply">券配额申请</el-button>
                <el-button v-else type="warning" size="small" class="blue-btn" @click="goToAuth">去企业认证</el-button>
              </div>
            </div>
            <div class="rz-item">
              <div class="label">支付信息认证</div>
              <div class="value">
                <div class="status-tag" :class="userInfo?.isPayAuth === 1 ? 'green' : 'orange'">
                  {{ userInfo?.isPayAuth | companyAuthFilter }}</div>
                <el-button v-if="!userInfo?.isPayAuth" type="primary" size="small" plain class="blue-btn"
                  @click="goToPayAuth('pay')">一键认证</el-button>
              </div>
            </div>
            <div class="rz-item">
              <div class="label">开票信息认证</div>
              <div class="value">
                <div class="status-tag" :class="userInfo?.isInvoiceAuth === 1 ? 'green' : 'orange'">
                  {{ userInfo?.isInvoiceAuth | companyAuthFilter }}</div>
                <el-button v-if="!userInfo?.isInvoiceAuth" type="primary" size="small" plain class="blue-btn"
                  @click="goToPayAuth('invoce')">一键认证</el-button>
              </div>
            </div>
            <!-- <div class="rz-item">
              <div class="label">签章认证</div>
              <div class="value">
                <div class="status-tag" :class="SignVerifyStatus == 1 ? 'green' : 'orange'">
                  {{SignVerifyStatus == 1 ? '已认证' : '未认证'}}</div>
                <el-button type="primary" size="small" plain class="blue-btn"
                  @click="goToContactAuth"> {{SignVerifyStatus == 1 ? '编辑' : '去认证'}}</el-button>
              </div>
            </div> -->
            <div class="rz-item">
              <div class="label">服务券签约机构资格</div>
              <div class="value">
                <div class="status-tag" :class="userInfo?.isCompanyService === 1 ? 'green' : 'orange'">
                  {{ userInfo?.isCompanyService | isCompanyServiceFilter }}</div>
                <el-button v-if="!userInfo?.isCompanyService" type="primary" size="small" plain class="blue-btn"
                  @click="goToServiceCompanyApply">申请入驻</el-button>
                <el-button v-else type="primary" size="small" class="blue-btn"
                  @click="goToServiceProductManage">上架服务</el-button>
              </div>
            </div>
            <div v-if="userInfo?.isCompanyService === 1 && hasUnionPayType" class="rz-item">
              <div class="label">银联签约状态</div>
              <div class="value">
                <div class="status-tag" :class="payerConfigStatus === 1 ? 'green' : 'orange'">
                  {{ payerConfigStatus === 1 ? '已签约' : '未签约' }}
                </div>
                <div>
                    <el-button v-if="payerConfigStatus !== 1" type="plain" size="small" plain class="blue-btn"
                      @click="goToUnionPayProcess">签约流程</el-button>
                    <el-button v-else type="plain" size="small" plain class="blue-btn"
                      @click="downloadUnionPayManual">根据商户手册登录商户统一平台</el-button>
                    <div v-if="payerConfigStatus === 1">商户号：{{ unionPayMerchantId }}
                      <el-button size="small" type="text" @click="showBankDetails">查看更多</el-button>
                    </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </el-col>

    <!-- 服务券信息 -->
    <el-col :span="9" class="pd15 height-24">
      <div class="info-card">
        <div class="head row-start-col-center">
          <div class="title">服务券信息</div>
        </div>
        <div class="content">
          <div class="coupon-wrap">
            <div class="coupon-item">
              <div class="label">{{ couponInfo.year }}年度</div>
              <div class="value">
                <div class="coupon-block">
                  <div class="coupon-head">
                    <div class="coupon-title">年度可申请额度（元）</div>
                    <div class="year">{{ couponInfo.year }}年</div>
                  </div>
                  <div>
                    <div v-if="voucherList.find(item => item.voucherTypeName === '通用券')" class="row-end width-24 coupon-content">
                      <div class="coupon-label">通用券</div>
                      <div class="coupon-value">{{ $priceToThousands(voucherList.find(item => item.voucherTypeName === '通用券')?.totalSum) }}</div>
                    </div>
                    <div v-else class="row-end width-24 coupon-content">
                      <div class="coupon-label">通用券</div>
                      <div class="coupon-value">待领取</div>
                    </div>
                    <div v-if="voucherList.find(item => item.voucherTypeName.includes('专项券'))" class="row-spaceb-col-center width-24 coupon-content">
                      <div class="row-end-col-center">
                          <div class="coupon-label" style="color:rgb(67,106,247)">融资担保</div>
                          <div class="coupon-value" style="color:rgb(67,106,247)">{{ $priceToThousands(voucherList.find(item => item.voucherTypeName.includes('融资担保'))?.totalSum) }}</div>
                      </div>
                      <div class="row-end-col-center">
                          <div class="coupon-label" style="color:rgb(67,106,247)">设备租赁</div>
                          <div class="coupon-value" style="color:rgb(67,106,247)">{{ $priceToThousands(voucherList.find(item => item.voucherTypeName.includes('设备租赁'))?.totalSum) }}</div>
                      </div>
                    </div>
                    <div v-else class="row-spaceb-col-center width-24 coupon-content" style="color:rgb(67,106,247)">
                      <div class="coupon-label">专项券</div>
                      <div class="coupon-value">待领取</div>
                    </div>
                  </div>
                </div>
                <div class="coupon-block">
                  <div class="coupon-head">
                    <div class="coupon-title">年度剩余额度（元）</div>
                    <div class="year">{{couponInfo.year }}年</div>
                  </div>
                  <div>
                    <div v-if="voucherList.find(item => item.voucherTypeName === '通用券')" class="row-spaceb-col-center width-24 coupon-content">
                      <div class="coupon-label">通用券</div>
                      <div class="coupon-value">{{ $priceToThousands(voucherList.find(item => item.voucherTypeName === '通用券')?.balanceSum) }}</div>
                    </div>
                    <div v-else class="row-spaceb-col-center width-24 coupon-content">
                      <div class="coupon-label">通用券</div>
                      <div class="coupon-value"> --</div>
                    </div>
                    <div v-if="voucherList.find(item => item.voucherTypeName.includes('专项券'))" class="row-spaceb-col-center width-24 coupon-content">
                      <div class="row-start-col-center">
                          <div class="coupon-label" style="color:rgb(67,106,247)">融资担保</div>
                          <div class="coupon-value" style="color:rgb(67,106,247)">{{ $priceToThousands(voucherList.find(item => item.voucherTypeName.includes('融资担保'))?.balanceSum) }}</div>
                      </div>
                      <div class="row-start-col-center">
                          <div class="coupon-label" style="color:rgb(67,106,247)">设备租赁</div>
                          <div class="coupon-value" style="color:rgb(67,106,247)">{{ $priceToThousands(voucherList.find(item => item.voucherTypeName.includes('设备租赁'))?.balanceSum) }}</div>
                      </div>
                    </div>
                    <div v-else class="row-spaceb-col-center width-24 coupon-content" style="color:rgb(67,106,247)">
                      <div class="coupon-label">专项券</div>
                      <div class="coupon-value"> --</div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div v-if="userInfo.isCompanyService" class="ml15 color-grey">
            <div>服务商补贴额度信息：</div>
            <div class="pl30 pr50">
              <div class="mt10 row-spaceb"><div>年度补贴额度：</div><div class="tr">{{ $priceToThousands(subsidyMoney?.quotaAll)}}元</div></div>
              <div class="mt10 row-spaceb"><div>合同结算金额：</div><div class="tr">{{ $priceToThousands(subsidyMoney?.discountAll)}}元</div></div>
              <div class="mt10 row-spaceb"><div>应结算金额：</div><div class="tr">{{ $priceToThousands(subsidyMoney?.subsidyAll)}}元</div></div>
              <div class="mt10 row-spaceb"><div>已结算金额：</div><div class="tr">{{ $priceToThousands(subsidyMoney?.subsidyAuditPassed)}}元</div></div>
            </div>
        </div>
        <div class="row-center mt20">
          <div class="advertisement">
              <el-button type="primary" plain size="small" class="button1" @click="creatRequirement">发布需求</el-button>
          </div>
        </div>
      </div>
    </el-col>
    <!-- 一键认证填报 -->
    <el-dialog title="企业信息一键认证" :visible.sync="authVisible" width="1300px" custom-class="my-dialog">
      <el-steps :active="step" align-center finish-status="success" style="margin-top: -10px;">
        <el-step title="企业信息"></el-step>
        <el-step title="指定经办人"></el-step>
        <el-step title="认证成功"></el-step>
      </el-steps>
      <div v-if="step === 0" class="mt20">
          <div class="color-primary mb20 tc">
              <i class="el-icon-warning-outline"></i> 企业信息会影响服务券配额额度，请确保信息填写的正确性。
          </div> 
          <div v-if="authForm.isManufacturing === null" class="ml50 mr50">
               <h3 class="mb20 tl">请选择身份：</h3>
               <div class="company-type-selection">
                  <div class="company-type-option" @click="selectCompanyType(1)">
                    <i class="el-icon-document"></i>
                    <div class="option-text">
                      <h4>我是制造业企业</h4>
                      <p>(可申领通用券，也可以提供服务)</p>
                    </div>
                  </div>
                  <div class="company-type-option mt30" @click="selectCompanyType(0)">
                    <i class="el-icon-goods"></i>
                    <div class="option-text">
                      <h4>我是非制造业企业</h4>
                      <p>(申请入驻提供服务，不可领取优惠券)</p>
                    </div>
                  </div>
                  <div class="company-type-option mt30 mb30" @click="selectCompanyType(2)">
                    <i class="el-icon-goods"></i>
                    <div class="option-text">
                      <h4>我是设备更新企业</h4>
                      <p>(可申领通用券、设备更新专项券)</p>
                    </div>
                  </div>
              </div>
          </div>
          <div v-else>     
          <el-form v-if="authStep == 0" :model="authForm" :rules="authRules" ref="authFormStep0"
            label-width="214px" size="medium" class="width-20" label-suffix=":">
                <el-form-item label="企业名称/机构名称" prop="companyName">
                  <el-input v-model="authForm.companyName" placeholder="请输入企业名称/机构名称" />
                </el-form-item>
                <el-form-item v-if="authForm.isManufacturing === 1" label="企业所属行业分类" required prop="industry">
                  <el-select v-model="authForm.industry" placeholder="请选择" style="width:100%">
                    <el-option
                          v-for="option in industryDict"
                          :key="option.dictValue"
                          :label="option.dictLabel"
                          :value="option.dictValue"
                        ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="统一社会信用代码" prop="creditCode">
                  <el-input v-model="authForm.creditCode" placeholder="请输入统一社会信用代码" />
                </el-form-item>
                <el-form-item label="法定代表人姓名" prop="legalName">
                  <el-input v-model="authForm.legalName" placeholder="请输入法定代表人姓名" />
                </el-form-item>
                <el-form-item label="法定代表人证件号码" prop="legalIdCard">
                  <el-input v-model="authForm.legalIdCard" placeholder="请输入居民身份证/港澳台居民通行证/外国人永久居留证" />
                </el-form-item>
                <el-form-item label="联系电话" prop="companyPhone">
                  {{userInfo?.userPhoneNum}}
                </el-form-item>
                <el-form-item label="短信验证码" prop="smsCode">
                  <el-input v-model="authForm.smsCode" placeholder="请输入短信验证码">
                    <template #append>
                      <el-button :disabled="countdown > 0" @click="getSmsCode">{{ countdown > 0 ? `${countdown}秒` : '获取验证码' }}</el-button>
                    </template>
                  </el-input>
                </el-form-item>
                <el-form-item prop="agree">
                  <el-checkbox-group v-model="authForm.agree">
                    <el-checkbox label="agree" name="agree">已阅读并同意<a class="protocol">《统一认证平台认证服务协议》</a></el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
                <el-form-item style="text-align: center">
                  <el-button type="primary" @click="authForm.isManufacturing = null" style="margin-top: 10px" class="blue-btn">上一步</el-button>
                  <el-button v-if="authForm.isManufacturing === 2" type="primary" @click="validateAndNextStep(0)" style="margin-top: 10px" class="blue-btn">下一步</el-button>
                  <el-button v-else type="primary" @click="validateAndNextStep(0)" style="margin-top: 10px" class="blue-btn">提交</el-button>
                </el-form-item>
            </el-form>
           <el-form v-if="authStep == 1 && authForm.isManufacturing === 1" :model="authForm.basicInfo" :rules="authRules" ref="authFormStep1"
             label-width="214px" size="medium" class="width-20" label-suffix=":">
              <h3 class="mb10 ml20">一、企业基本信息</h3>
              <el-form-item label="企业所属行业分类" required prop="industry">
                <el-select v-model="authForm.basicInfo.industry" placeholder="请选择">
                  <el-option
                        v-for="option in industryDict"
                        :key="option.dictValue"
                        :label="option.dictLabel"
                        :value="option.dictValue"
                      ></el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-table :data="economicIndicators" border style="width: 100%">
                  <el-table-column label="* 经济效益指标" prop="label" width="200px"></el-table-column>
                  <el-table-column label="前年">
                    <template #default="scope">
                      <el-input v-model.number="authForm.basicInfo[scope.row.prop].theYearBeforeLast"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="上年">
                    <template #default="scope">
                      <el-input v-model.number="authForm.basicInfo[scope.row.prop].lastYear"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="同比增减 (%)">
                    <template #default="scope">
                      {{ calculateGrowthRate(authForm.basicInfo[scope.row.prop].lastYear, authForm.basicInfo[scope.row.prop].theYearBeforeLast) }}
                    </template>
                  </el-table-column>
                  <el-table-column label="当年预计">
                    <template #default="scope">
                      <el-input v-model.number="authForm.basicInfo[scope.row.prop].thisYear"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="同比增减 (%)">
                      <template #default="scope">
                        {{ calculateGrowthRate(authForm.basicInfo[scope.row.prop].thisYear, authForm.basicInfo[scope.row.prop].lastYear) }}
                      </template>
                  </el-table-column>
                </el-table>
              </el-form-item>
              <el-form-item label="先进管理方式采用情况" required prop="managementStyle">
                <el-radio-group v-model="authForm.basicInfo.managementStyle">
                  <el-radio v-for="item in managementStyleDict" :key="item.dictValue" :label="item.dictValue">
                    {{ item.dictLabel }}
                  </el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="是否运用专门的企业管理软件" required prop="softwareType">
                <el-radio-group v-model="authForm.basicInfo.softwareType">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="0">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="企业管理软件名称" v-if="authForm.basicInfo.softwareType === 1">
                <el-input v-model="authForm.basicInfo.softwareName" disabled placeholder="请输入企业管理软件名称"></el-input>
              </el-form-item>
              <el-form-item label="其他软件名称" v-if="authForm.basicInfo.softwareType === 0">
                <el-input v-model="authForm.basicInfo.softwareName" placeholder="请输入企业管理软件名称"></el-input>
              </el-form-item>
              <el-form-item label="企业获得的管理体系认证情况" required prop="managementSystemCertification">
                <el-radio-group v-model="authForm.basicInfo.managementSystemCertification">
                  <el-radio
                        v-for="item in systemCertificationDict"
                        :key="item.dictValue"
                        :label="item.dictValue"
                      >
                        {{ item.dictLabel }}
                  </el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item style="text-align: center">
                <el-button type="primary" @click="prevStep" class="blue-btn">上一步</el-button>
                <el-button type="primary" @click="validateAndNextStep(1)" class="blue-btn">下一步</el-button>
              </el-form-item>
           </el-form>
            <el-form v-if="authStep == 2" :model="authForm" :rules="authRules" ref="authFormStep2" label-width="214px" size="medium" class="width-20" label-suffix=":">
              <h3 class="mb10 ml20">二、专业化指标</h3>
              <el-form-item>
                <el-table :data="productExport" border style="width: 100%">
                  <el-table-column label="指标" prop="label" width="180"></el-table-column>
                  <el-table-column label="前年">
                    <template #default="scope">
                      <el-form-item>
                        <el-input v-model.number="authForm.professionalIndicator[scope.row.prop].theYearBeforeLast"></el-input>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="上年">
                    <template #default="scope">
                      <el-form-item>
                        <el-input v-model.number="authForm.professionalIndicator[scope.row.prop].lastYear"></el-input>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="同比增减 (%)">
                    <template #default="scope">
                      {{ calculateGrowthRate(authForm.professionalIndicator[scope.row.prop].lastYear, authForm.professionalIndicator[scope.row.prop].theYearBeforeLast) }}
                    </template>
                  </el-table-column>
                  <el-table-column label="当年预计">
                    <template #default="scope">
                      <el-form-item>
                        <el-input v-model.number="authForm.professionalIndicator[scope.row.prop].thisYear"></el-input>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="同比增减 (%)">
                    <template #default="scope">
                      {{ calculateGrowthRate(authForm.professionalIndicator[scope.row.prop].thisYear, authForm.professionalIndicator[scope.row.prop].lastYear) }}
                    </template>
                  </el-table-column>
                </el-table>
              </el-form-item>
              <h3 class="mb10 ml20">三、精细化指标</h3>
               <el-form-item label="产品生产达到标准" prop="productionStandard" required>
                <el-radio-group v-model="authForm.productionStandard">
                  <el-radio
                        v-for="item in productionStandardDict"
                        :key="item.dictValue"
                        :label="item.dictValue"
                      >
                        {{ item.dictLabel }}
                  </el-radio>
                </el-radio-group>
              </el-form-item>
              <h3 class="mb10 ml20">四、新颖型指标</h3>
              <el-form-item label="是否是有效期内的高新技术企业" prop="highTech" label-width="400px" required>
                <el-radio-group v-model="authForm.highTech">
                  <el-radio :label="true">是</el-radio>
                  <el-radio :label="false">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item 
                v-for="(item, index) in intellectualPropertyItems" 
                :key="index"
                :label="item.label"
                :prop="item.prop"
                label-width="400px"
              >
                <el-input-number 
                  v-model="authForm[item.prop]" 
                  :min="0" 
                  controls-position="right"
                ></el-input-number>
              </el-form-item>
              <el-form-item style="text-align: center">
                <el-button type="primary" @click="prevStep" class="blue-btn">上一步</el-button>
                <el-button :loading="loading" type="primary" @click="oneClickAuth" class="blue-btn">提交</el-button>
              </el-form-item>
          </el-form>
          <el-form v-if="authStep == 1 && authForm.isManufacturing === 2" :model="authForm" :rules="upgradeProjectRules" ref="authFormStep1"
             label-width="214px" size="medium" class="width-20" label-suffix=":">
              <h3 class="mb10 ml20">自治区新型工业化领域资金(工业企业技术改造升级项目)</h3>
              <el-form-item label="项目名称" prop="projectName" required>
                <el-input v-model="authForm.projectName" placeholder="请输入项目名称" />
              </el-form-item>
              <el-form-item label="项目内容" prop="projectContent" required>
                <el-input type="textarea" v-model="authForm.projectContent" placeholder="请输入项目内容" :rows="4" />
              </el-form-item>
              <h4 class="mb10 ml20">项目投资情况</h4>
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item label="总投资" prop="totalInvestment" required>
                    <el-input v-model.number="authForm.totalInvestment" placeholder="请输入金额">
                  <template #append>元</template>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="固定资产投资" prop="fixedAssetInvestment" required>
                    <el-input v-model.number="authForm.fixedAssetInvestment" placeholder="请输入金额">
                      <template #append>元</template>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="设备投资" prop="equipmentInvestment" required>
                    <el-input v-model.number="authForm.equipmentInvestment" placeholder="请输入金额">
                      <template #append>元</template>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="项目累计完成投资" prop="accumulatedInvestment" required>
                    <el-input v-model.number="authForm.accumulatedInvestment" placeholder="请输入金额">
                      <template #append>元</template>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="累计完成设备投资" prop="accumulatedEquipmentInvestment" required>
                    <el-input v-model.number="authForm.accumulatedEquipmentInvestment" placeholder="请输入金额">
                      <template #append>元</template>
                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <h4 class="mb10 ml20">前期审批手续情况</h4>
              <el-row :gutter="20">
                <el-col :span="12">
                <el-form-item label="项目核准备案文号" prop="projectRegistrationDocNo" required>
                  <el-input v-model="authForm.projectRegistrationDocNo" placeholder="请输入" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="节能审查文号" prop="energySavingDocNo" required>
                  <el-input v-model="authForm.energySavingDocNo" placeholder="请输入" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="环评审批文号" prop="environmentImpactDocNo" required>
                  <el-input v-model="authForm.environmentImpactDocNo" placeholder="请输入" />
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item
                  prop="compilesWithKeyDirection"
                  required
                  label-width="600px"
                  label="项目是否符合《工业重点行业领域设备更新和技术改造指南》重点方向"
                >
                  <el-radio-group v-model="authForm.compilesWithKeyDirection">
                    <el-radio :label="1">是</el-radio>
                    <el-radio :label="0">否</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label-width="300px" label="是否纳入技术改造类别统计" prop="includedInTechnicalTransformationCategories" required>
                <el-radio-group v-model="authForm.includedInTechnicalTransformationCategories">
                    <el-radio :label="1">是</el-radio>
                    <el-radio :label="0">否</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label-width="300px" label="项目建设性质" prop="natureOfProjectConstruction" required>
                  <el-radio-group v-model="authForm.natureOfProjectConstruction">
                  <el-radio :label="1">是</el-radio>
                    <el-radio :label="0">否</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item  label-width="300px" label="是否已入设备更新库或已获得资金项目支持" prop="includedInDatabase" required>
                  <el-radio-group v-model="authForm.includedInDatabase">
                    <el-radio :label="1">是</el-radio>
                    <el-radio :label="0">否</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label-width="300px"  label="是否列入严重失信主体名单" prop="onTheListOfSeriousDishonestEntities" required>
                  <el-radio-group v-model="authForm.onTheListOfSeriousDishonestEntities">
                    <el-radio :label="1">是</el-radio>
                    <el-radio :label="0">否</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              </el-row>
              <el-form-item style="text-align: center">
                <el-button type="primary" @click="prevStep" class="blue-btn">上一步</el-button>
                <el-button type="primary" @click="validateAndNextStep(1)" class="blue-btn">提交</el-button>
              </el-form-item>
            </el-form>
          </div>
      </div>
      <div v-else-if="step === 1" class="mt20 col-center">
          <div class="color-primary mb20 tc">
              <i class="el-icon-warning-outline"></i> 
               1、指定经办人后，将由经办人代理法人在此平台完成服务券配额申领、申请成为服务商、服务交易等操作；
               2、如无指定经办人，默认将由法人自行完成上述操作。
          </div> 
          <el-form :model="step1Form" :rules="step1FormRules" ref="step1FormRules" label-width="180px" class="width-20">
            <el-form-item label="指定经办人" prop="agentStatus">
              <el-radio-group v-model="step1Form.agentStatus" @change="handleAgentStatusChange">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
            <template v-if="step1Form.agentStatus == 1">
              <el-form-item  label="经办人姓名" prop="agentName">
                <el-input v-model="step1Form.agentName" placeholder="请输入经办人姓名"></el-input>
              </el-form-item>
              <el-form-item label="经办人身份证号" prop="agentIdCard">
                <el-input v-model="step1Form.agentIdCard" placeholder="请输入经办人身份证号"></el-input>
              </el-form-item>
            </template>
          </el-form>
          <div class="tc">
            <el-button type="primary" @click="completeFace" style="margin-top: 30px" class="blue-btn">下一步</el-button>
          </div>
      </div>
      <div v-else class="res-box mt20" >
            <i class="el-icon-success green"></i>
            <div class="res-text">企业信息认证成功</div>
            <el-button type="info" @click="authVisible = false" size="medium" style="margin: 113px 0 30px 0">返回</el-button>
      </div>
    </el-dialog>
    <el-dialog title="请输入图形验证码确认" width="400px" :visible.sync="showPhoneDialog">
      <el-input v-model="imgcode" placeholder="请输入图形验证码">
        <template #append>
          <img @click="getPhoneCaptcha" style="cursor: pointer;height:38px" :src="phoneCaptchaObj?.img"  />
        </template>
      </el-input>
      <span slot="footer" class="dialog-footer">
        <el-button @click="showPhoneDialog = false">取 消</el-button>
        <el-button :loading="confirmLoading" type="primary" @click="getSmsCode">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 需要认证提示 -->
    <el-dialog :title="tipTitle" :visible.sync="tipVisible" width="525px" custom-class="my-dialog" :close-on-click-modal="false">
      <p style="margin-top: -10px;">需要完成<span
          style="color: #436AF7;">"企业信息认证"</span>才可进行相关操作。</p>
      <div style="text-align: right;margin-top: 40px;">
        <el-button type="info" size="medium" @click="tipVisible = false">暂不认证</el-button>
        <el-button type="primary" size="medium" class="blue-btn"
          @click="() => { tipVisible = false; goToAuth() }">一键认证</el-button>
      </div>
    </el-dialog>
    <el-dialog title="签章认证" :visible.sync="contactAuthVisible" width="80%" custom-class="my-dialog" top="10" @close="closeContactAuth" :close-on-click-modal="false">
      <div class="tc relposition">
           <iframe v-if="signUrl" :src="signUrl" frameborder="0" width="100%" height="860px"></iframe>
           <div class="minitips row-start">
              <div>
                <div class="mt20">点击<span class="color-primary">授权</span>后，使用微信扫码</div>
                <div class="mt10">登录 <span class="color-primary">广西桂在益企小程序</span></div>
                <div class="mt10">完成 <strong class="color-primary">企业刷脸验证</strong></div>
                <div class="mt10">才可完成签章认证！</div>
             </div>
             <div class="mt10 ml20">
               <img src="@/assets/image/miniCode.jpg" class="ml30"  alt="face" style="width: 100px;height: 100px;" />
             </div>
           </div>
      </div>
    </el-dialog>
      <!-- 需要认证提示 -->
      <el-dialog title="温馨提示" :visible.sync="bankVisible" width="525px" custom-class="my-dialog">
        <p style="margin-top: -10px;">为避免影响款项到账，请在合同签订前完成银联签约。</p>
        <div style="text-align: right;margin-top: 40px;">
          <el-button type="primary" size="medium" class="blue-btn"
            @click="bankDetail">了解详情</el-button>
          <el-button type="info" size="medium" @click="bankVisible = false">暂不处理</el-button>
        </div>
      </el-dialog>
      <el-dialog
        title="银行通道信息"
        :visible.sync="bankDetailsVisible"
        width="600px">
        <el-table
          :data="bankChannels"
          empty-text="暂无银行通道信息"
          style="width: 100%">
          <el-table-column
            prop="bankWayName"
            label="银行通道名称"
            width="180">
          </el-table-column>
          <el-table-column
            prop="bankMerchantNo"
            label="银行商户号"
            width="180">
          </el-table-column>
          <el-table-column
            prop="bankCardNo"
            label="银行卡号">
          </el-table-column>
        </el-table>
      </el-dialog>
  </el-row>
</template>

<script>
import QRCode from 'qrcodejs2'
import { mapGetters } from 'vuex'
import { getcode,companyAuth,sendAuthCompanyCode,voucherPage,userinfo, 
  signVerifyUrl, getSignVerifyStatus, subsidySummary,updateAgentInfo,getAgentInfo,manualSignVerifyUrl,
  payerConfigStatus
} from '@/api/homeApi'
var validateCreditCode = (rule, value, callback) => {
    var reg = /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/;
    if (value === '') {
      callback(new Error('请输入统一企业信用代码'));
    } else if (!reg.test(value)) {
      callback(new Error('请输入正确的统一企业信用代码'));
    } else {
      callback();
    }
};
var legalIdCardCode = (rule, value, callback) => {
    var reg = /(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0[1-9]|10|11|12)([0-2]\d|30|31)\d{3}(\d|X)$)/;
    if (value === '') {
      callback(new Error('请输入法定代表人身份证号码'));
    } else if (!reg.test(value)) {
      callback(new Error('请输入正确的法定代表人身份证号码'));
    } else {
      callback();
    }
};
var validateNumber = (rule, value, callback) => {
      if (value === '' || value === null) {
        callback(new Error('请输入数值'));
      } else if (isNaN(Number(value))) {
        callback(new Error('请输入有效的数值'));
      } else {
        callback();
      }
 };
export default {
  filters: {
    userAuthFilter: function (value) {
      let res = ''
      switch (value) {
        case 0:
          res = '待认证'
          break;
        case 1:
          res = '已认证'
          break;
        default:
          break;
      }
      return res;
    },
    companyAuthFilter: function (value) {
      let res = ''
      switch (value) {
        case 0:
          res = '未认证'
          break;
        case 1:
          res = '已认证'
          break;
        default:
          break;
      }
      return res;
    },
    isVoucherApplicableFilter: function (value) {
      let res = ''
      switch (value) {
        case 0:
          res = '不可领取'
          break;
        case 1:
          res = '可领取'
          break;
        default:
          break;
      }
      return res;
    },
    isCompanyServiceFilter: function (value) {
      let res = ''
      switch (value) {
        case 0:
          res = '待入驻'
          break;
        case 1:
          res = '已入驻'
          break;
        default:
          break;
      }
      return res;
    },
    unionPayAuthFilter: function (value) {
      let res = ''
      switch (value) {
        case 0:
          res = '未签约'
          break;
        case 1:
          res = '已签约'
          break;
        default:
          break;
      }
      return res;
    },
  },

  data() {
    return {
      authStep:0,
      bankVisible: false,
      step: 0,
      captchaObj: {
        img: '',
        uuid: ''
      },
      // 个人信息
      personInfo: {
        userName: 'admin',
        avator: '',
        qrcode: 'test',
        relativeCompany: ['广西北投软件股份有限公司'],
        companyType: '自治区创新性中小企业'
      },
      // 服务券信息
      couponInfo: {
        year: new Date().getFullYear(),
        yearCommon: 50000,
        yearSpecial: '未领取',
        remainCommon: 50000,
        remainSpecial: '未领取',
      },
      // 状态
      status: {
        auth: false,
        apply: false,
        company: false,
        pay: false
      },
      // 一键认证填报
      authVisible: false,
      authForm: {
        isManufacturing:null,
        companyName: '',
        creditCode: '',
        legalName: '',
        legalIdCard: '',
        code: '',
        smsCode: null,
        agree: [],
        industry:'',
        basicInfo: {
          industry: '',
          income: { thisYear: 0, lastYear: 0, theYearBeforeLast: 0 },
          profit: { thisYear: 0, lastYear: 0, theYearBeforeLast: 0 },
          netProfit: { thisYear: 0, lastYear: 0, theYearBeforeLast: 0 },
          asset: { thisYear: 0, lastYear: 0, theYearBeforeLast: 0 },
          assetLiabilityRatio: { thisYear: 0, lastYear: 0, theYearBeforeLast: 0 },
          payTax: { thisYear: 0, lastYear: 0, theYearBeforeLast: 0 },
          employeeCount: { thisYear: 0, lastYear: 0, theYearBeforeLast: 0 },
          bachelorCount: { thisYear: 0, lastYear: 0, theYearBeforeLast: 0 },
          managementStyle: null,
          softwareType: 0,
          softwareName: "ERP",
          managementSystemCertification: '',
        },
        // 专业化指标
        professionalIndicator: {
          productExport: { thisYear: 0, lastYear: 0, theYearBeforeLast: 0 }
        },
        // 精细化指标
        productionStandard: null,
        // 新颖型指标
        highTech: true,
        intellectualPropertyRight: 0,
        authorizedPatent: 0,
        inventionPatent: 0,
        utilityModelPatent: 0,
        designPatent: 0,
        softwareCopyright: 0,
        projectName: "",
        projectContent: "",
        totalInvestment: 0,
        fixedAssetInvestment: 0,
        equipmentInvestment: 0,
        accumulatedInvestment: 0,
        accumulatedEquipmentInvestment: 0,
        projectRegistrationDocNo: "",
        energySavingDocNo: "",
        environmentImpactDocNo: "",
        compilesWithKeyDirection: 0,
        includedInTechnicalTransformationCategories: 0,
        natureOfProjectConstruction: 0,
        includedInDatabase: 0,
        onTheListOfSeriousDishonestEntities: 0,
      },
			industries: [
					{ dictLabel: "农副食品加工业", dictValue: 1 },
					{ dictLabel: "食品制造业", dictValue: 2 },
					{ dictLabel: "酒、饮料和精制茶制造业", dictValue: 3 },
					{ dictLabel: "烟草制品业", dictValue: 4 },
					{ dictLabel: "纺织业", dictValue: 5 },
					{ dictLabel: "纺织服装、服饰业", dictValue: 6 },
					{ dictLabel: "皮革、毛皮、羽毛及其制品和制鞋业", dictValue: 7 },
					{ dictLabel: "木材加工和木、竹、藤、棕、草制品业", dictValue: 8 },
					{ dictLabel: "家具制造业", dictValue: 9 },
					{ dictLabel: "造纸和纸制品业", dictValue: 10 },
					{ dictLabel: "印刷和记录媒介复制业", dictValue: 11 },
					{ dictLabel: "文教、工美、体育和娱乐用品制造业", dictValue: 12 },
					{ dictLabel: "石油、煤炭及其他燃料加工业", dictValue: 13 },
					{ dictLabel: "化学原料和化学制品制造业", dictValue: 14 },
					{ dictLabel: "医药制造业", dictValue: 15 },
					{ dictLabel: "化学纤维制造业", dictValue: 16 },
					{ dictLabel: "橡胶和塑料制品业", dictValue: 17 },
					{ dictLabel: "非金属矿物制品业", dictValue: 18 },
					{ dictLabel: "黑色金属冶炼和压延加工业", dictValue: 19 },
					{ dictLabel: "有色金属冶炼和压延加工业", dictValue: 20 },
					{ dictLabel: "金属制品业", dictValue: 21 },
					{ dictLabel: "通用设备制造业", dictValue: 22 },
					{ dictLabel: "专用设备制造业", dictValue: 23 },
					{ dictLabel: "汽车制造业", dictValue: 24 },
					{ dictLabel: "铁路、船舶、航空航天和其他运输设备制造业", dictValue: 25 },
					{ dictLabel: "电气机械和器材制造业", dictValue: 26 },
					{ dictLabel: "计算机、通信和其他电子设备制造业", dictValue: 27 },
					{ dictLabel: "仪器仪表制造业", dictValue: 28 },
					{ dictLabel: "其他制造业", dictValue: 29 },
					{ dictLabel: "废弃资源综合利用业", dictValue: 30 },
					{ dictLabel: "金属制品、机械和设备修理业", dictValue: 31 }
			],
      economicIndicators: [
        { label: '营业收入（万元）', prop: 'income' },
        { label: '利润总额（万元）', prop: 'profit' },
        { label: '净利润总额（万元）', prop: 'netProfit' },
        { label: '资产总额（万元）', prop: 'asset' },
        { label: '资产负债率（%）', prop: 'assetLiabilityRatio' },
        { label: '上缴税金', prop: 'payTax' },
        { label: '从业人数', prop: 'employeeCount' },
        { label: '其中：本科及以上学历人数', prop: 'bachelorCount' }
      ],
      productExport:[
        {label:'产品出口总额(万美元)',prop:'productExport'}
      ],
      intellectualPropertyItems: [
        { label: '企业累计拥有核心自主知识产权（有效期内）数量（项）', prop: 'intellectualPropertyRight' },
        { label: '获得授权专利（有效期内）数量（项）', prop: 'authorizedPatent' },
        { label: '累计发明专利（有效期内）数量（项）', prop: 'inventionPatent' },
        { label: '累计实用专利（有效期内）数量（项）', prop: 'utilityModelPatent' },
        { label: '累计外观设计专利（有效期内）数量（项）', prop: 'designPatent' },
        { label: '累计软件著作权（有效期内）数量（项）', prop: 'softwareCopyright' }
      ],
      authRules: {
        companyName: [{ required: true, message: '请输入企业名称/机构名称', trigger: 'blur' }],
        creditCode: [{ required: true, validator: validateCreditCode, trigger: 'blur' }],
        legalName: [{ required: true, message:'请输入法定代表人姓名', trigger: 'blur' }],
        legalIdCard: [{ required: true, message:'请输入法定代表人证件号码', trigger: 'blur' }],
        code: [{ required: true, message: '请输入图片验证码', trigger: 'blur' }],
        smsCode: [{ required: true, message: '请输入短信验证码', trigger: 'blur' }],
        agree: [{ required: true, message: '需要同意协议', trigger: 'change' }],
        industry: [
          { required: true, message: '请选择企业所属行业分类', trigger: 'change' }
        ],
        managementStyle: [
          { required: true, message: '请选择先进管理方式', trigger: 'change' }
        ],
        softwareType: [
          { required: true, message: '请选择是否使用企业管理软件', trigger: 'change' }
        ],
        managementSystemCertification: [
          { required: true, message: '请选择管理体系认证情况', trigger: 'change' }
        ],
        productionStandard: [{ required: true, message: '请选择产品生产达到标准', trigger: 'change' }],
        highTech: [{ required: true, message: '请选择是否是有效期内的高新技术企业', trigger: 'change' }],
      },
      // 需要认证提示
      tipTitle: '',
      tipVisible: false,
      formOrLoading: 'form',//'form'显示form表单,'loading'显示加载，'result'显示提交结果
      companyTypeDict: [],//企业划型字典
      industryDict: [
      ],
      managementStyleDict: [
      ],
      systemCertificationDict: [
      ],
      productionStandardDict: [
      ],
      imgCodeObj: { // 认证图形验证码对象
        img: '',
        uuid: ''
      },
      phoneCaptchaObj: { // 短信图形验证码对象
        img: '',
        uuid: ''
      },
      imgcode: '',
      showPhoneDialog: false,
      phoneScence: 6,
      confirmLoading: false,
      countdown: 0,
      voucherList: [],
      contactAuthVisible: false,
      signUrl: '',
      SignVerifyStatus: 0,
      subsidyMoney:{
        quotaAll:0,
        discountAll:0,
        subsidyAll:0,
        subsidyAuditPassed:0
      },
      loading: false,
      step1Form: {
        agentStatus: 1,
        agentIdType: 0,
        agentName: null,
        agentIdCard: null
      },
      step1FormRules: {
        agentStatus: [
          { required: true, message: '请选择是否指定经办人', trigger: 'change' }
        ],
        agentName: [
          { required: true, message: '请输入经办人姓名', trigger: 'blur' }
        ],
        agentIdCard: [
          { required: true, message: '请输入经办人身份证号', trigger: 'blur' }
        ]
      },
      upgradeProjectRules:{
        projectName: [
          {required: true, message: '请输入项目名称', trigger: 'blur'}
        ],
        projectContent: [
          {required: true, message: '请输入项目内容', trigger: 'blur'}
        ],
        totalInvestment: [
          {required: true, message: '请输入总投资', trigger: 'blur'},
          {type: 'number', message: '总投资必须为数字', trigger: 'blur'}
        ],
        fixedAssetInvestment: [
          {required: true, message: '请输入固定资产投资', trigger: 'blur'},
          {type: 'number', message: '固定资产投资必须为数字', trigger: 'blur'}
        ],
        equipmentInvestment: [
          {required: true, message: '请输入设备投资', trigger: 'blur'},
          {type: 'number', message: '设备投资必须为数字', trigger: 'blur'}
        ],
        accumulatedInvestment: [
          {required: true, message: '请输入项目累计完成投资', trigger: 'blur'},
          {type: 'number', message: '项目累计完成投资必须为数字', trigger: 'blur'}
        ],
        accumulatedEquipmentInvestment: [
          {required: true, message: '请输入累计完成设备投资', trigger: 'blur'},
          {type: 'number', message: '累计完成设备投资必须为数字', trigger: 'blur'}
        ],
        projectRegistrationDocNo: [
          {required: true, message: '请输入项目核准备案文号', trigger: 'blur'}
        ],
        energySavingDocNo: [
          {required: true, message: '请输入节能审查文号', trigger: 'blur'}
        ],
        environmentImpactDocNo: [
          {required: true, message: '请输入环评审批文号', trigger: 'blur'}
        ],
        compilesWithKeyDirection: [
          {required: true, message: '请选择是否符合重点方向', trigger: 'change'}
        ],
        includedInTechnicalTransformationCategories: [
          {required: true, message: '请选择是否纳入技术改造类别统计', trigger: 'change'}
        ],
        natureOfProjectConstruction: [
          {required: true, message: '请选择项目建设性质', trigger: 'change'}
        ],
        includedInDatabase: [
          {required: true, message: '请选择是否已入设备更新库', trigger: 'change'}
        ],
        onTheListOfSeriousDishonestEntities: [
          {required: true, message: '请选择是否列入严重失信主体名单', trigger: 'change'}
        ]
      },
      payerConfigStatus: 0,
      unionPayMerchantId: '-',
      bankDetailsVisible: false,
      bankChannels: []
    }
  },
  computed: {
    ...mapGetters([
      'userInfo', 'commonDict'
    ]),
    companyTypeName() {
      let target = this.companyTypeDict?.find(item => item.dictValue == this.userInfo?.companyType)
      return target?.dictLabel || '-'
    },
    economicIndicatorsWithGrowth() {
      return this.economicIndicators.map(indicator => {
        const data = this.authForm[indicator.prop];
        return {
          ...indicator,
          growthRateLast: this.calculateGrowthRate(data.lastYear, data.theYearBeforeLast),
          growthRateThis: this.calculateGrowthRate(data.thisYear, data.lastYear)
        };
      });
    },
    hasUnionPayType() {
      return this.userInfo?.supplierTypes?.includes(1)
    }
  },
  created() {
// 为经济指标和知识产权项添加动态验证规则
    this.economicIndicators.forEach(indicator => {
      ['thisYear', 'lastYear', 'theYearBeforeLast'].forEach(year => {
        this.$set(this.authRules, `${indicator.prop}.${year}`, [
          { required: true, validator: validateNumber, trigger: 'blur' }
        ]);
      });
    });
    this.intellectualPropertyItems.forEach(item => {
      this.$set(this.authRules, `${item.prop}`, [
        { required: true, validator: validateNumber, trigger: 'blur' }
      ]);
    });
  },
  mounted() {
    if (this.commonDict.length === 0) {
          this.$store.dispatch('getCommonDict').then(() => {
            for (const item of Object.values(this.commonDict)) {
                if (item.dictType === 'sme_company_type') {
                  this.companyTypeDict.push(...item.dictData)
                }
                if (item.dictType === 'sme_industry') {
                  this.industryDict.push(...item.dictData)
                }
                if (item.dictType === 'sme_management_style') {
                  this.managementStyleDict.push(...item.dictData)
                }
                if (item.dictType === 'sme_management_system_certification') {
                  this.systemCertificationDict.push(...item.dictData)
                }
                if (item.dictType === 'sme_production_standard') {
                  this.productionStandardDict.push(...item.dictData)
                }
            }
          })
        }else{
            for (const item of Object.values(this.commonDict)) {
                if (item.dictType === 'sme_company_type') {
                  this.companyTypeDict.push(...item.dictData)
                }
                if (item.dictType === 'sme_industry') {
                  this.industryDict.push(...item.dictData)
                }
                if (item.dictType === 'sme_management_style') {
                  this.managementStyleDict.push(...item.dictData)
                }
                if (item.dictType === 'sme_management_system_certification') {
                  this.systemCertificationDict.push(...item.dictData)
                }
                if (item.dictType === 'sme_production_standard') {
                  this.productionStandardDict.push(...item.dictData)
                }
            }
        }
      if(this.$refs.qrcodeRef) {
        new QRCode(this.$refs.qrcodeRef, {
          text: this.userInfo?.companyName,
          width: 158,
          height: 158
        })
      }
      if(this.userInfo?.isVoucherApplicable == 1){
        this.getVoucherTypeList()
      }
      if(this.userInfo?.isCompanyService){
        this.getSubsidySummary()
        this.getPayerConfigStatus()
      }
    this.getSignVerifyStatus()

  },
  methods: {
    nextStep(){
      // authStep：0-法人信息，1- 企业基本信息，2-专业化指标
      if(this.authStep == 0){
           if(this.authForm.isManufacturing == 0){
              this.oneClickAuth()
           }else {
            this.authStep++
           }
      }else {
        this.authStep++
      }
    },
    prevStep(){
      this.authStep--
    },
    getPayerConfigStatus(){
      payerConfigStatus().then(res => {
        if(res.code === 200){
          this.payerConfigStatus = res.data.status;
          this.unionPayMerchantId = res.data.businessMerchantNo || '-';
          this.bankChannels = res.data.bankChannels || []
        }
      })
    },
    validateAndNextStep(step) {
      const formRef = `authFormStep${step}`;
      this.$refs[formRef].validate((valid) => {
        if (valid) {
          if(step === 0){
              // 只有专项券会进入下一页了，另外两个直接提交
              if (this.authForm.isManufacturing === 2) {
                this.nextStep();
              } else {
                this.oneClickAuth();
              }          
          } else if(step === 1){
              this.oneClickAuth();
          }
        }
      });
    },
    selectCompanyType(type) {
         this.authForm.isManufacturing = type
    },
    calculateGrowthRate(newValue, oldValue) {
      if (!oldValue || oldValue === 0) return '-';
      const rate = (newValue - oldValue) / oldValue;
      return (rate * 100).toFixed(2) + '%';
    },
    bankDetail() {
      this.bankVisible = false
      open(`${process.env.VUE_APP_PUBLIC_FILE_URL}/bankDetail/index.html`)
    },
    creatRequirement(){
      // this.$router.push({name:'发布需求'})
      this.tipTitle = '提示'
      if(!this.userInfo?.isAuth){
        this.tipVisible = true
      } else {
        this.$router.push({name:'我的需求管理'})
      }
    },
    getSubsidySummary(){
      subsidySummary().then(res => {
        if (res.code === 200) {
          this.subsidyMoney = res.data
        }
      })
    },
    getSignVerifyStatus(){
      getSignVerifyStatus().then(res => {
        if (res.code === 200) {
          this.SignVerifyStatus = res.data
        }
      })
    },
    goToContactAuth() {
       signVerifyUrl({redirectUrl:`${process.env.VUE_APP_PUBLIC_FILE_URL}/transfer?code=c40001&msg=认证完成`}).then(res => {
         if (res.code === 200) {
           this.signUrl = res.data
           this.contactAuthVisible = true
         }
       })
    },
    closeContactAuth() {
      this.getSignVerifyStatus()
      this.contactAuthVisible = false
    },
    handleAgentStatusChange(value) {
        if (value === 1) {
          // 选择"是"，清空经办人姓名
          this.step1Form.agentName = '';
          this.step1Form.agentIdCard = '';
        } else {
          // 选择"否"，赋值法人姓名和身份证号
          this.step1Form.agentName = null;
          this.step1Form.agentIdCard = null;
        }
    },
    completeFace() {
      // userinfo().then(res => {
      //   const { data } = res
      //   if (data.isAuth) {
      //     this.step = 2
      //     this.$store.dispatch('user/getUserInfo')
      //   } else {
      //     this.$message.error('未完成人脸认证')
      //   }
      // })
      this.$refs.step1FormRules.validate((valid) => {
        if (valid) {
          // Handle form submission
          updateAgentInfo(this.step1Form).then(res => {
            if (res.code === 200) {
              this.step = 2
              this.$store.dispatch('user/getUserInfo')
            }
          })
          // You can call your API here to submit the representative information
        } else {
          console.log('Form validation failed');
          return false;
        }
      });
    },
    getImgCode() {
      getcode().then(res => {
        this.imgCodeObj.img = 'data:image/png;base64,' + res.img;
        this.imgCodeObj.uuid = res.uuid;
      });
    },
    // 一键认证时点击获取手机验证码按钮
    authGetSmsCode() {
        this.showPhoneDialog = true;
        // 企业认证的场景是6
        this.phoneScence = 6;
        this.getPhoneCaptcha()
    },
    // 获得图形验证码确认弹窗内的图形验证码
    getPhoneCaptcha() {
      getcode().then(res => {
        this.phoneCaptchaObj.img = 'data:image/png;base64,' + res.img;
        this.phoneCaptchaObj.uuid = res.uuid;
      });
    },
    // 图形验证码确认弹窗的确认按键，从而发送短信验证码
    getSmsCode() {
      this.confirmLoading = true;
      sendAuthCompanyCode({code:this.imgcode,uuid:this.phoneCaptchaObj.uuid}).then(res => {
        if (res.code === 200) {
          this.$message.success('验证码发送成功！');
          this.showPhoneDialog = false;
          this.countdown = 60;
          const timer = setInterval(() => {
            this.countdown--;
            if (this.countdown <= 0) {
              clearInterval(timer);
            }
          }, 1000);
        }else{
          this.getPhoneCaptcha();
        }
      }).finally(() => {
        this.confirmLoading = false;
      });
    },
    goToAuth() {
      this.formOrLoading = 'form'
      this.authVisible = true
      this.authForm.isManufacturing = null
      if(this.userInfo?.isCompanyAuth){
        this.step = 1
      } else if(this.userInfo?.isAuth){
        this.step = 2 
        this.step1Form.agentName = this.authForm.legalName
      }
      this.getImgCode()
    },
    updataAgentInfo(){
      getAgentInfo().then(res => {
        if(res.code === 200){
          this.step1Form.agentName = res.data.agentName
        }
      }).finally(() => {
        this.authVisible = true
        this.step = 1
      })
    },
    oneClickAuth() {
      const formRef = `authFormStep${this.authStep}`;
      this.$refs[formRef].validate(valid => {
        if (valid) {
           const restructuredData = {
            ...this.authForm,
            basicInfo:{
              industry: this.authForm.industry
            },
            refinedIndicator: {
              productionStandard: this.authForm.productionStandard
            },
            innovativenessIndicator: {
              highTech: this.authForm.highTech,
              intellectualPropertyRight: this.authForm.intellectualPropertyRight,
              authorizedPatent: this.authForm.authorizedPatent,
              inventionPatent: this.authForm.inventionPatent,
              utilityModelPatent: this.authForm.utilityModelPatent,
              designPatent: this.authForm.designPatent,
              softwareCopyright: this.authForm.softwareCopyright
            },
            upgradeProjectInfo: {
              projectName: this.authForm.projectName,
              projectContent: this.authForm.projectContent,
              totalInvestment: this.authForm.totalInvestment,
              fixedAssetInvestment: this.authForm.fixedAssetInvestment,
              equipmentInvestment: this.authForm.equipmentInvestment,
              accumulatedInvestment: this.authForm.accumulatedInvestment,
              accumulatedEquipmentInvestment: this.authForm.accumulatedEquipmentInvestment,
              projectRegistrationDocNo: this.authForm.projectRegistrationDocNo,
              energySavingDocNo: this.authForm.energySavingDocNo,
              environmentImpactDocNo: this.authForm.environmentImpactDocNo,
              compilesWithKeyDirection: this.authForm.compilesWithKeyDirection,
              includedInTechnicalTransformationCategories: this.authForm.includedInTechnicalTransformationCategories,
              natureOfProjectConstruction: this.authForm.natureOfProjectConstruction,
              includedInDatabase: this.authForm.includedInDatabase,
              onTheListOfSeriousDishonestEntities: this.authForm.onTheListOfSeriousDishonestEntities,
            }
          };
          companyAuth(restructuredData).then(res => {
            if (res.code === 200) {
              this.$message.success('提交成功！');
              this.step = 1
              this.$store.dispatch('user/getUserInfo')
            }
          })
        }
      })
    },
    goToCouponApply() {
      if (this.userInfo?.isCompanyAuth) {
          this.$router.push({name:'服务券配额申请'})
      } else {
        this.tipTitle = '服务券配额申请'
        this.tipVisible = true
      }
    },
    goToCouponManage() {
      this.$router.push({name:'服务券配额申请'})
    },
    goToServiceCompanyApply() {
      if (this.userInfo?.isCompanyAuth) {
        this.$router.push({name:'申请入驻平台'})
      } else {
        this.tipTitle = '服务券签约机构'
        this.tipVisible = true
      }
    },
    goToServiceProductManage() {
      this.$router.push({name:'服务产品管理'})
    },
    goToPayAuth(val) {
      if (this.userInfo?.isCompanyAuth) {
        this.$emit('goToPayAuth',val)
      } else {
        this.tipTitle = '认证提醒'
        this.tipVisible = true
      }
    },
    // 获取已申请服务券配额列表
    getVoucherTypeList(){
      voucherPage({pageNo:1,pageNum:50,isAudit:1}).then(res => {
        if (res.code === 200) {
          this.voucherList = res.rows
        }
      })
    },
    openSignUrl(){
      let url = `${process.env.VUE_APP_PUBLIC_FILE_URL}/personalCenter/profile`
      manualSignVerifyUrl({returnUrl:url,linkType:1}).then(res => {
          if(res.code === 200){
            window.open(res.data)
          }
      })
    },
    goToUnionPayAuth() {
      if (this.userInfo?.isCompanyAuth) {
        // 跳转到银联签约页面
        this.$router.push({name:'银联签约'})
      } else {
        this.tipTitle = '银联签约'
        this.tipVisible = true
      }
    },
    downloadUnionPayManual() {
      // 下载银联商户手册
      window.open(`${process.env.VUE_APP_PUBLIC_FILE_URL}/商户手册.pdf`)
    },
    goToUnionPayProcess() {
      window.open('https://www.gxgeq.com/bankDetail/index.html')
    },
    showBankDetails() {
      this.bankDetailsVisible = true
    },
  }
}
</script>

<style lang="scss" scope>
@import "@/assets/css/element-variables";
.advertisement{
  width: 200px;
  height: 230px;
  background-image: url('~@/assets/image/advertisement.png');
  background-size: 100% 100%;
  position: relative;
}
company-type-selection {
  display: flex;
  justify-content: space-around;
  margin-top: 30px;
}

.company-type-option {
  display: flex;
  align-items: center;
  padding: 20px;
  border: 2px solid #dcdfe6;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;

  &:hover {
    border-color: #409eff;
    box-shadow: 0 0 10px rgba(64, 158, 255, 0.3);
  }

  i {
    font-size: 48px;
    margin-right: 20px;
    color: #409eff;
  }

  .option-text {
    h4 {
      margin: 0 0 10px;
      font-size: 18px;
      color: #303133;
    }

    p {
      margin: 0;
      font-size: 14px;
      color: #606266;
    }
  }
}
.codebox{
  width: 685px;
  height: 215px;
  background: #F7F8FA;
  border-radius: 5px 5px 5px 5px;
}

.BaseInfo {
  padding: 0 15px 0 25px;
  height: calc(80vh - 80px);

  div {
    box-sizing: border-box;
  }

  .info-card {
    height: 100%;
    color: $text-color;
    box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.16);
    position: relative;
    &.bg-grey {
      background-color: rgba(118, 134, 163, 0.05);
    }

    .head {
      padding: 10px 20px;
      min-height: 40px;
      font-size: 14px;
      background: #F7F8F9;

      .title {
        flex: 1;
      }

    }

    .content {
      .status-tag {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 63px;
        height: 27px;
        border-radius: 3px;
        font-size: 14px;

        &.green {
          color: $--color-success;
          background: rgba(3, 194, 153, 0.1);

        }

        &.orange {
          color: #FA5330;
          background: rgba(250, 83, 48, 0.1);
        }

      }

      .user-wrap {
        position: relative;
        padding: 15px 20px 20px;
        background-color: #fff;

        &::after {
          content: '';
          position: absolute;
          left: 20px;
          right: 30px;
          bottom: 0;
          display: block;
          height: 1px;
          background-color: #E8E8E8;
        }

        .avatar {
          width: 38%;
          height: 38%;
          max-width: 78px;
          max-height: 78px;
        }

        .user-info {
          flex: 1;
          margin-left: 26px;
          overflow: hidden;

          .name {
            font-size: 18px;
            text-overflow: ellipsis;
            overflow: hidden;
          }

          .status {
            margin-top: 14px;
          }
        }
      }

      .company-wrap {

        padding: 20px;
        background-color: transparent;

        .info-item {
          &+.info-item {
            margin-top: 20px;
          }

          .label {
            font-size: 14px;
            color: #7686A3;
          }

          .value {
            margin-top: 10px;

            .text {}

            .desc {
              margin-top: 10px;
              color: $--color-primary;
            }

            .qrcode {
              margin-top: 25px;
              display: flex;
              // justify-content: center;

              canvas,
              img {
                width: 70%;
                height: 70%;
                max-width: 158px;
                max-height: 158px;
              }
            }
          }
        }
      }

      .rz-wrap {
        padding: 15px 25px 20px 20px;

        .rz-item {
          &+.rz-item {
            margin-top: 28px;
          }

          .label {
            font-size: 14px;
            color: #7686A3;
          }

          .value {
            margin-top: 10px;
            display: flex;
            justify-content: space-between;
            align-items: center;

            .status-tag {
              min-width: 80px;
              padding: 0 10px;
            }

            .blue-btn {
              min-width: 120px;
            }
          }
        }
      }

      .coupon-wrap {
        padding: 20px;

        .coupon-item {
          &+.coupon-item {
            margin-top: 28px;
          }

          .label {
            font-size: 14px;
            color: #7686A3;
          }

          .value {
            margin-top: 12px;

            .coupon-block {
              position: relative;
              // padding: 12px 30px 16px 22px;
              // max-width: 307px;
              height: 75px;
              background: url('~@/assets/image/coupon_bg.png') no-repeat;
              background-size: 100% 100%;

              &+.coupon-block {
                top: -1px;

                &::before {
                  content: '';
                  position: absolute;
                  top: 0;
                  left: 1px;
                  right: 1px;
                  border-top: 1px dashed #FA5330;
                }
              }

              .coupon-head {
                padding: 12px 10% 0 7%;
                display: flex;
                justify-content: space-between;
                font-size: 14px;
                color: #7686A3;

                .coupon-title {
                  position: relative;
                  padding-left: 10px;

                  &::before {
                    content: '';
                    position: absolute;
                    top: 3px;
                    left: 0;
                    display: block;
                    width: 4px;
                    height: 4px;
                    background-color: #FA5330;
                    border-radius: 50%;
                  }
                }
              }

              .coupon-content {
                margin-top: 4px;
                padding: 0 10% 0 7%;
                color: #FA5330;

                .coupon-label {
                  font-size: 14px;
                }

                .coupon-value {
                  flex: 1;
                  font-size: 14px;
                  text-align: right;
                   margin-left: 10px;
                }

                .right {
                  .coupon-label {
                    text-align: right;
                  }

                  .coupon-value {
                    text-align: right;
                    margin-left: 10px;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  .button1{
    background: #FFFFFF;
    border-radius: 20px;
    border: 1px solid #436AF7;
    color: #436AF7;
    font-size: 18px;
    margin-right:40px;
    position: absolute;
    bottom: 20px;
    left: 30%;
}
  .minitips{
    background: #fff;
    position: absolute;
    bottom: 15%;
    left: 40%;
  }

  .protocol {
    white-space: nowrap;
    color: rgba(58, 65, 198, 1);
  }

  .rectCode {
    position: absolute;
    width: 75px;
    height: 34px;
    background: #BBB;
    top: 1px;
    left: calc(100% + 5px);
    cursor: pointer;

    img {
      width: 100%;
      height: 100%;
    }
  }

  .blue-btn {
    background-color: $--color-primary;
    border: 1px solid $--color-primary;
    color: #fff;
    border-radius: 3px;
    font-size: 14px;

    &.is-plain {
      color: $--color-primary;
      background-color: #fff;
    }
  }

  .loading-box {
    display: flex;
    justify-content: center;
    margin: -10px -10px;
    height: 424px;
    background: url('~@/assets/image/loading_bg.png') no-repeat;
    background-size: 100% 100%;

    .loading-text {
      display: inline-block;
      margin-top: 18px;
      font-size: 26px;
      color: $text-color;

      p {
        margin: 0;
        margin-top: 7px;
      }
    }
  }

  .res-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    i {
      margin-top: 100px;
      font-size: 48px;

      &.green {
        color: $--color-success;
      }
    }

    .res-text {
      margin-top: 40px;
      font-size: 26px;
    }
  }
}
@import "@/assets/css/element-variables";

:deep(.el-step__title.is-success) {
  color: $text-color;
}

:deep(.el-step__head.is-success) {
  color: $text-color-blue;
  border-color: $text-color-blue;
}

:deep(.el-step__title.is-process) {
  color: $text-color-blue !important;
}

:deep(.el-step__head.is-success .el-step__line-inner) {
  // transition-delay: 0ms;
  border-width: 1px !important;
  width: 100% !important;
}

:deep(.el-step__head.is-process) {
  color: $text-color-blue;
  border-color: $text-color-blue;
}

:deep(.el-step__title.is-process) {
  font-weight: 400;
  color: rgb(122, 121, 121);
}

:deep(.el-step__title.is-wait) {
  color: rgb(122, 121, 121);
}
</style>
